package com.rd.student.jiaji.class3.xumingze.day728;

import java.io.*;

public class Test {

    public static void main(String[] args) throws Exception{
        File file = new File("all.txt");
        String[] str = new String[]{
          "徐铭泽 ","才雨鑫 ","张世煊 "
        };
        String hh = "";
        for(int i = 0;i < str.length;i++){
            hh += str[i];
        }
        Writer writer = new FileWriter(file);
        writer.write(hh);
        writer.close();

        int n = 9;
        RandomAccessFile file1 = new RandomAccessFile(file,"rw");
        file1.seek(n);
        Reader reader = new FileReader(file);
        byte[] arr = new byte[1024];
        file1.read(arr);
        System.out.println(new String(arr));
        reader.close();

        InputStream is = new FileInputStream(file);
        OutputStream os = new FileOutputStream("random.txt");
        int len = 0;

        while ((len = is.read(arr)) != -1){
            os.write(arr,n,len);
            os.write(arr,0,n);
        }
        os.close();
        is.close();
    }
}
